package com.xiao.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutConfig {
    @Bean
    public DirectExchange exchange() {
        return ExchangeBuilder.directExchange("new.direct").build();
    }

    @Bean
    public Queue queue1() {
        return QueueBuilder.durable("direct.queue1").build();
    }

    @Bean
    public Queue queue2() {
        return QueueBuilder.durable("direct.queue2").build();
    }

    @Bean
    public Queue queue3() {
        return QueueBuilder.durable("direct.queue3").build();
    }

    @Bean
    public Binding bind1(Queue queue1, DirectExchange exchange) {
        return BindingBuilder.bind(queue1).to(exchange).with("red");
    }

    @Bean
    public Binding bind2(Queue queue2, DirectExchange exchange) {
        return BindingBuilder.bind(queue2).to(exchange).with("blue");
    }

    @Bean
    public Binding bind3(Queue queue3, DirectExchange exchange) {
        return BindingBuilder.bind(queue3).to(exchange).with("red");
    }

}
